import Mock from 'mockjs'

// 设置延迟时间
Mock.setup({
  timeout: '300-600'
})

// 通用响应
const successResponse = {
  code: 200,
  message: 'success',
  data: null
}

// 用户管理
Mock.mock(/\/api\/v1\/User\/List/, 'get', {
  code: 200,
  message: 'success',
  'data|10': [{
    'id|+1': 1,
    username: '@name',
    nickname: '@cname',
    'status|1': [0, 1],
    email: '@email',
    phone: /^1[3456789]\d{9}$/,
    avatar: '@image("100x100")',
    'roleIds|1-3': ['@integer(1, 10)'],
    createTime: '@datetime',
    remark: '@cparagraph(1, 2)'
  }],
  total: 100
})

// 角色管理
Mock.mock(/\/api\/v1\/Role\/List/, 'get', {
  code: 200,
  message: 'success',
  'data|10': [{
    'id|+1': 1,
    name: '@ctitle(4, 8)',
    code: '@word(4, 8)',
    'status|1': [0, 1],
    createTime: '@datetime',
    remark: '@cparagraph(1, 2)'
  }],
  total: 100
})

// 用户相关接口
Mock.mock(/\/api\/v1\/User\/Add/, 'post', successResponse)
Mock.mock(/\/api\/v1\/User\/Update/, 'put', successResponse)
Mock.mock(/\/api\/v1\/User\/Delete\/\d+/, 'delete', successResponse)
Mock.mock(/\/api\/v1\/User\/BatchDelete/, 'delete', successResponse)
Mock.mock(/\/api\/v1\/User\/UpdateStatus/, 'put', successResponse)

// 角色相关接口
Mock.mock(/\/api\/v1\/Role\/Add/, 'post', successResponse)
Mock.mock(/\/api\/v1\/Role\/Update/, 'put', successResponse)
Mock.mock(/\/api\/v1\/Role\/Delete\/\d+/, 'delete', successResponse)
Mock.mock(/\/api\/v1\/Role\/BatchDelete/, 'delete', successResponse)
Mock.mock(/\/api\/v1\/Role\/UpdateStatus/, 'put', successResponse)

// 菜单相关接口
Mock.mock(/\/api\/v1\/Menu\/Add/, 'post', successResponse)
Mock.mock(/\/api\/v1\/Menu\/Update/, 'put', successResponse)
Mock.mock(/\/api\/v1\/Menu\/Delete\/\d+/, 'delete', successResponse)
Mock.mock(/\/api\/v1\/Menu\/UpdateStatus/, 'put', successResponse)

// 权限相关接口
Mock.mock(/\/api\/v1\/Auth\/Add/, 'post', successResponse)
Mock.mock(/\/api\/v1\/Auth\/Update/, 'put', successResponse)
Mock.mock(/\/api\/v1\/Auth\/Delete\/\d+/, 'delete', successResponse)
Mock.mock(/\/api\/v1\/Auth\/UpdateStatus/, 'put', successResponse)

// 角色权限
Mock.mock(/\/api\/v1\/Role\/GetPermissions\/\d+/, 'get', {
  code: 200,
  message: 'success',
  data: {
    menuIds: [1, 2, 3, 4],
    deptIds: [1, 2],
    dataScope: '1'
  }
})

Mock.mock(/\/api\/v1\/Role\/AssignPermissions/, 'post', successResponse)

// 用户角色
Mock.mock(/\/api\/v1\/User\/GetRoles\/\d+/, 'get', {
  code: 200,
  message: 'success',
  data: {
    roleIds: [1, 2]
  }
})

Mock.mock(/\/api\/v1\/User\/AssignRoles/, 'post', successResponse)

// 租户管理相关接口
Mock.mock(/\/api\/v1\/Tenant\/List/, 'get', {
  code: 200,
  message: 'success',
  'data|10': [{
    'id|+1': 1,
    name: '@company',
    code: /[A-Z0-9]{8}/,
    contactPerson: '@cname',
    contactPhone: /^1[3-9]\d{9}$/,
    address: '@county(true)',
    'status|1': [0, 1],
    expireTime: '@datetime',
    createTime: '@datetime',
    remark: '@cparagraph(1, 2)'
  }],
  total: 100
})

Mock.mock(/\/api\/v1\/Tenant\/Add/, 'post', successResponse)
Mock.mock(/\/api\/v1\/Tenant\/Update/, 'put', successResponse)
Mock.mock(/\/api\/v1\/Tenant\/Delete\/\d+/, 'delete', successResponse)
Mock.mock(/\/api\/v1\/Tenant\/UpdateStatus/, 'put', successResponse) 